home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / cvs-1_3.lha / cvs-1.3 / src / admin.c < prev    next >
C/C++ Source or Header  |  1992-03-31  |  3KB  |  125 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.3 kit.
  7.  * 
  8.  * Administration
  9.  * 
  10.  * For now, this is basically a front end for rcs.  All options are passed
  11.  * directly on.
  12.  */
  13.  
  14. #include "cvs.h"
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "@(#)admin.c 1.17 92/03/31";
  18. #endif
  19.  
  20. #if __STDC__
  21. static Dtype admin_dirproc (char *dir, char *repos, char *update_dir);
  22. static int admin_fileproc (char *file, char *update_dir,
  23.                char *repository, List *entries,
  24.                List *srcfiles);
  25. #else
  26. static int admin_fileproc ();
  27. static Dtype admin_dirproc ();
  28. #endif                /* __STDC__ */
  29.  
  30. static char *admin_usage[] =
  31. {
  32.     "Usage: %s %s rcs-options files...\n",
  33.     NULL
  34. };
  35.  
  36. static int ac;
  37. static char **av;
  38.  
  39. int
  40. admin (argc, argv)
  41.     int argc;
  42.     char *argv[];
  43. {
  44.     int err;
  45.  
  46.     if (argc <= 1)
  47.     usage (admin_usage);
  48.  
  49.     /* skip all optional arguments to see if we have any file names */
  50.     for (ac = 1; ac < argc; ac++)
  51.     if (argv[ac][0] != '-')
  52.         break;
  53.     argc -= ac;
  54.     av = argv + 1;
  55.     argv += ac;
  56.     ac--;
  57.     if (ac == 0 || argc == 0)
  58.     usage (admin_usage);
  59.  
  60.     /* start the recursion processor */
  61.     err = start_recursion (admin_fileproc, (int (*) ()) NULL, admin_dirproc,
  62.                (int (*) ()) NULL, argc, argv, 0,
  63.                W_LOCAL, 0, 1, (char *) NULL, 1);
  64.     return (err);
  65. }
  66.  
  67. /*
  68.  * Called to run "rcs" on a particular file.
  69.  */
  70. /* ARGSUSED */
  71. static int
  72. admin_fileproc (file, update_dir, repository, entries, srcfiles)
  73.     char *file;
  74.     char *update_dir;
  75.     char *repository;
  76.     List *entries;
  77.     List *srcfiles;
  78. {
  79.     Vers_TS *vers;
  80.     char *version;
  81.     char **argv;
  82.     int argc;
  83.     int retcode = 0;
  84.  
  85.     vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL,
  86.                file, 0, 0, entries, srcfiles);
  87.  
  88.     version = vers->vn_user;
  89.     if (version == NULL)
  90.     return (0);
  91.     else if (strcmp (version, "0") == 0)
  92.     {
  93.     error (0, 0, "cannot admin newly added file `%s'", file);
  94.     return (0);
  95.     }
  96.  
  97.     run_setup ("%s%s", Rcsbin, RCS);
  98.     for (argc = ac, argv = av; argc; argc--, argv++)
  99.     run_arg (*argv);
  100.     run_arg (vers->srcfile->path);
  101.     if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0)
  102.     {
  103.     if (!quiet)
  104.         error (0, retcode == -1 ? errno : 0,
  105.            "%s failed for `%s'", RCS, file);
  106.     return (1);
  107.     }
  108.     return (0);
  109. }
  110.  
  111. /*
  112.  * Print a warm fuzzy message
  113.  */
  114. /* ARGSUSED */
  115. static Dtype
  116. admin_dirproc (dir, repos, update_dir)
  117.     char *dir;
  118.     char *repos;
  119.     char *update_dir;
  120. {
  121.     if (!quiet)
  122.     error (0, 0, "Administrating %s", update_dir);
  123.     return (R_PROCESS);
  124. }
  125.